package com.senlingspace.web.controller.douyin;


import com.senlingspace.common.core.domain.AjaxResult;
import com.senlingspace.common.utils.StringUtils;
import com.senlingspace.payment.douyin.DouyinHttpClient;
import com.senlingspace.payment.douyin.bean.request.DouyinPoiMatchQueryRequest;
import com.senlingspace.payment.douyin.bean.request.DouyinShopQueryRequest;
import com.senlingspace.payment.douyin.bean.response.DouyinPoiMatchQueryResponse;
import com.senlingspace.payment.douyin.bean.response.DouyinShopQueryResponse;
import com.senlingspace.payment.douyin.service.DouYinShopService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

/**
 * 抖音商家控制器
 */

@Slf4j
@Validated
@AllArgsConstructor
@RestController
@RequestMapping(path = "/douyin/shop/v1")
public class DouYinShopController {

    private final DouYinShopService douYinShopService;

    /**
     * 根据抖音提供的account_id查询抖音门店信息
     */
    @GetMapping(path = "/query")
    public AjaxResult prepare(DouyinShopQueryRequest request) {
        DouyinShopQueryResponse invoke = douYinShopService.prepare(request);
        return AjaxResult.success(invoke);
    }


    /**
     * 根据本系统门店id查询抖音门店id
     * 参数：三方门店 id 列表，多个使用,分隔，单次请求 <= 200
     */
    @GetMapping(path = "/queryID")
    public AjaxResult queryID(DouyinPoiMatchQueryRequest request) {

        String extIds = request.getExtIds();
        DouyinPoiMatchQueryResponse invoke = null;
        if (StringUtils.isNotBlank(extIds)) {
            invoke = DouyinHttpClient.invoke(request);
        }
        return AjaxResult.success(invoke);
    }


}
